<?php
namespace App\Services;

use Swoft\Auth\Mapping\AuthServiceInterface;
use Swoft\Auth\AuthUserService;
use Psr\Http\Message\ServerRequestInterface;
use Swoft\Bean\Annotation\Bean;
use Swoft\Bean\Annotation\Inject;

/**
 * @Bean()
 */
class AuthService extends AuthUserService implements AuthServiceInterface
{

    public function auth(string $requestHandler, ServerRequestInterface $request): bool
    {
        $id = $this->getUserIdentity();
        $role = $this->getUserExtendData()['role'] ?? '' ;
        echo sprintf("你访问了: %s",$requestHandler);
        if($id){
            return true;
        }
        return false;
    }

}